//
//  main.m
//  03-HomeWork
//
//  Created by 李昊林 on 16/7/6.
//  Copyright © 2016年 李昊林. All rights reserved.
//
#import "Book.h"
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
//    1，截取字符串 "20|https://www.baidu.com" 中 "|" 前面和后⾯的字符串, 并输出
//    NSString * str = @"20|https://www.baidu.com";
//    NSArray *Array = [NSString componentsSeparatedByString:@"|"];
//    NSLog(@"%@",Array);
    NSString * string1 = @"20|https://www.baidu.com";
    NSArray *Array = [string1 componentsSeparatedByString:@"|"];
    NSLog(@"%@",Array);
    
//    2，向可变数组里存储 int、float、double、BOOL类型等数据(不能使用字面量)
    int a = 1;
    NSNumber * numberOfA = [NSNumber numberWithInt:a];
    float b = 1.2;
    NSNumber * numberOfB = [NSNumber numberWithFloat:b];
    double c = 2.0000;
    NSNumber * numberOfC = [NSNumber numberWithDouble:c];
    BOOL d = YES;
    NSNumber * numberOfD = [NSNumber numberWithBool:d];
    NSMutableArray * numberarray = [NSMutableArray arrayWithObjects:numberOfA,numberOfB,numberOfC,numberOfD, nil];
    NSLog(@"%@",numberarray);
    
    
//    3，实现图书管理系统(BookManager类)：
//    使用数组管理所有书籍(Book类)。
//    BookManager类属性数组可以添加、删除。
//    可以从数组根据书名查找书籍，并修改书籍的价格。
//    展示所有书籍清单（书名）
    Book *book = [[Book alloc] init];
    Book *book1 = [Book bookWithName:@"A" Price:46];
    Book *book2 = [Book bookWithName:@"B" Price:32];
    Book *book3 = [Book bookWithName:@"C" Price:50];
    Book *temp = [Book bookWithName:@"D" Price:99];
    
    NSMutableArray *bookArray = [NSMutableArray arrayWithObjects:book1, book2, book3, nil];
    
    
    [book addBookArray:bookArray Temp:temp];
    
    
    [book deleteBookArray:bookArray Temp:book2];
    
   
    for (int i = 0; i < bookArray.count; i++) {
        if ([[[bookArray objectAtIndex:i] name] isEqual: @"C"]) {
            [[bookArray objectAtIndex:i] setPrice:80];
        }
    }
    for (int i = 0; i < bookArray.count; i++) {
        NSLog(@"%@", [[bookArray objectAtIndex:i] name]);
    }
}

